from django.shortcuts import render
from mysqldb.header import *
from .serializers import *

# Create your views here.


class AllinpayWebGLListViewSet(viewsets.ModelViewSet):
    __title__ = "3D场景"
    __group__ = "3D场景模块"
    __info__ = {"get": "查询3D场景"}
    __doc__ = """	list:
    <h4>3D场景列表</h4>
    retrieve:
    <h4>3D场景详情</h4>
    create:
    <h4>创建</h4>
    update:
    <h4>编辑</h4>
    delete:
    <h4>移除</h4>"""
    http_method_names = ["get"]
    # authentication_classes = [
    #     MyJWTAuthentication,
    #     BoxJWTAuthentication,
    #     WeChatJWTAuthentication,
    # ]
    # permission_classes = [MyPermissions | BoxPermissions | WeChatPermissions]
    authentication_classes = []
    permission_classes = [AllPermissions]
    serializer_class = NoneSerializer
    queryset = None

    def list(self, request, *args, **kwargs):
        queryset = self.filter_queryset(self.get_queryset())
        serializer = self.get_serializer(queryset, many=True)
        return Response({"rescode": 200, "resmsg": serializer.data})

    def retrieve(self, request, *args, **kwargs):
        # print(args, kwargs)
        pk = kwargs.get("pk")
        # instance = self.get_object()
        # serializer = self.get_serializer(instance)
        # return Response({"rescode": 200, "resmsg": pk})
        return render(
            request, "WebGL/index.html", {"pid": pk, "api": "webgl/" + pk + ".js"}
        )


# 检查视图
filter_views(globals())
